﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;

namespace Mahanet.Abyss.PathCalculation
{
	public class SingleDataSourceMocker
	{
		#region Fields

		private IDataDisplayer m_DataDisplayer;
		private SingleDataManager m_DataManager;
		private SingleDataGenerator m_DataGenerator;

		#endregion

		#region C'tor

		public SingleDataSourceMocker(IDataDisplayer dataDisplayer)
		{
			this.m_DataDisplayer = dataDisplayer;
			this.m_DataGenerator = new SingleDataGenerator();
			this.m_DataManager = new SingleDataManager(m_DataDisplayer, m_DataGenerator);
		}

		#endregion

		#region Public Methods

		public void GenerateAndDisplayPoints(double maxX, double maxY, int numberOfPoints)
		{
			m_DataDisplayer.ClearPoints();

			m_DataGenerator.GenerateFunction();

			m_DataDisplayer.AddFunction("GeneratedData", t => new Coordinate2D(t, m_DataGenerator.GeneratedFunction(t)), Colors.Blue, 2);

			m_DataGenerator.GenerateDataPoints(Enumerable.Range(0, numberOfPoints).Select(i => (double)i * (maxX / (double)numberOfPoints)),
												0.1);

			m_DataManager.DisplayDataSeries(m_DataGenerator.LastDataSeriesId);
		}

		#endregion
	}
}
